using System;
using SharpMud.DynamicTyping;
using System.Xml.Serialization;
using SharpMud.Server.Systems.Scripting.Processing;

namespace SharpMud.MudLib.SAMPLE.Commands
{
	[XmlRoot("CommandTypeDefinition")]
	public class CommandTypeDefinition
	{
		#region Private Variables
		private string							_FileExtension;
		private AssembliedTypeLocation			_CodeDomProvider;
		private System.Collections.ArrayList	_AssemblyReferences;
        private IScriptCompileContext _ScriptCompileContext;
		#endregion

		#region Constructors
		public CommandTypeDefinition()
		{
			_FileExtension = null;
			_CodeDomProvider = null;
			_AssemblyReferences = new System.Collections.ArrayList();
		}
		public CommandTypeDefinition(string fileExtension, System.Type codeDomProvider, string[] assemblyReferences)
			:this(fileExtension,SharpMud.DynamicTyping.AssembliedTypeLocation.FromLoadedType(codeDomProvider),assemblyReferences)
		{
		}
		public CommandTypeDefinition(string fileExtension, AssembliedTypeLocation codeDomProvider, string[] assemblyReferences)
		{
			if(fileExtension==null || fileExtension==String.Empty)
				throw new ArgumentNullException("fileExtension");
			if(codeDomProvider==null)
				throw new ArgumentNullException("codeDomProvider");
			if(assemblyReferences==null)
				throw new ArgumentNullException("assemblyReferences");

			_FileExtension = fileExtension;
			_CodeDomProvider = codeDomProvider;
			_AssemblyReferences = new System.Collections.ArrayList(assemblyReferences);
		}
		#endregion

		#region Public Properties
		[XmlElement("FileExtension")]
		public string FileExtension
		{
			get
			{
				return this._FileExtension;
			}
			set
			{
				this._FileExtension = value;
			}
		}
		
		[XmlElement("CodeDomProvider")]
		public AssembliedTypeLocation CodeDomProvider
		{
			get
			{
				return this._CodeDomProvider;
			}
			set
			{
				this._CodeDomProvider = value;
			}
		}

		public string[] AssemblyReferences
		{
			get
			{
				return (string[])_AssemblyReferences.ToArray(typeof(string));
			}
			set
			{
				this._AssemblyReferences.AddRange(value);
			}
		}
		#endregion
	}
}
